package top.toptimus.dto.queryDto;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 订单全文检索条件DTO
 * TODO 时间检索
 *
 * @author gaoyu
 */
@NoArgsConstructor
@Data
public class OrderFullTextQueryDTO {
    private boolean fuzzyQuery; //  是否模糊查询，模糊查询就是textbox，非模糊查询对应列表
    private String displayName; //  控件显示名称
    private List<String> optionValues;  //  对应非模糊查询
    private boolean queryItemMatch; //  该查询项目被命中
    private String queryName;   //  查询的item，对应elasticsearch的query name
    private String queryText;   //  查询的value，对应elasticsearch的query text

    public OrderFullTextQueryDTO(
            boolean fuzzyQuery,
            String displayName,
            List<String> optionValues,
            boolean queryItemMatch,
            String queryName,
            String queryText
    ) {
        this.fuzzyQuery = fuzzyQuery;
        this.displayName = displayName;
        this.optionValues = optionValues;
        this.queryItemMatch = queryItemMatch;
        this.queryName = queryName;
        this.queryText = queryText;
    }

    /**
     * 模糊查询
     *
     * @param displayName 控件显示名称
     * @param queryName   查询的item，对应elasticsearch的query name
     * @return this
     */
    public OrderFullTextQueryDTO buildFuzzyQuery(String displayName, String queryName) {
        this.fuzzyQuery = true;
        this.displayName = displayName;
        this.queryName = queryName;
        return this;
    }

    /**
     * 非模糊查询
     *
     * @param displayName 控件显示名称
     * @param queryName   查询的item，对应elasticsearch的query name
     * @return this
     */
    public OrderFullTextQueryDTO buildMatchPhraseQuery(String displayName, String queryName, List<String> optionValues) {
        this.fuzzyQuery = false;
        this.displayName = displayName;
        this.queryName = queryName;
        this.optionValues = optionValues;
        return this;
    }
}
